Parse user CSS from $XDG_CONFIG_HOME/gtk-3.0/gtk.css
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 1 Dec 2010 01:55:31 +0000 (02:55 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Sat, 4 Dec 2010 14:39:53 +0000 (15:39 +0100)
gtk/gtkcssprovider.c
gtk/gtksettings.c
gtk/gtkstylecontext.c
gtk/gtkstyleprovider.h

index 35e94e8fafb86034c6deff52ff60fc961f3766aa..f1789051322545410588b55140ea250338521463 100644 (file)
@@ -47,7 +47,7 @@
  * calling gtk_css_provider_load_from_file() and adding the provider with
  * gtk_style_context_add_provider() or gtk_style_context_add_provider_for_screen().
  * In addition, certain files will be read when GTK+ is initialized. First,
- * the file <filename><replaceable>HOME</replaceable>/.gtk-3.0.css</filename>
+ * the file <filename><replaceable>XDG_CONFIG_HOME</replaceable>/gtk-3.0/gtk.css</filename>
  * is loaded if it exists. Then, GTK+ tries to load
  * <filename><replaceable>HOME</replaceable>/.themes/<replaceable>theme-name</replaceable>/gtk-3.0/gtk.css</filename>,
  * falling back to
index 58fd2c1f4d4535f680c3113f0cfc182c84eb7ad6..f57924b65e9eb260d41812e6c847dc69517efc4d 100644 (file)
@@ -1354,18 +1354,19 @@ settings_init_style (GtkSettings *settings)
   /* Add provider for user file */
   if (G_UNLIKELY (!css_provider))
     {
-      GFile *home_dir, *css_file;
+      gchar *css_path;
 
       css_provider = gtk_css_provider_new ();
+      css_path = g_build_filename (g_get_user_config_dir (),
+                                   "gtk-3.0",
+                                   "gtk.css",
+                                   NULL);
 
-      home_dir = g_file_new_for_path (g_get_home_dir ());
-      css_file = g_file_get_child (home_dir, ".gtk-3.0.css");
+      if (g_file_test (css_path,
+                       G_FILE_TEST_IS_REGULAR))
+        gtk_css_provider_load_from_path (css_provider, css_path, NULL);
 
-      if (g_file_query_exists (css_file, NULL))
-        gtk_css_provider_load_from_file (css_provider, css_file, NULL);
-
-      g_object_unref (home_dir);
-      g_object_unref (css_file);
+      g_free (css_path);
     }
 
   gtk_style_context_add_provider_for_screen (settings->screen,
index c458c244b4dca5e354d70500fefdfcf91ed0e369..65255402ff0a8737ca7fd47352edfab97dbad966 100644 (file)
  * If you are using custom styling on an applications, you probably want then
  * to make your style information prevail to the theme's, so you must use
  * a #GtkStyleProvider with the %GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
- * priority, keep in mind that the user settings in $HOME/.gtk-3.0.css will
+ * priority, keep in mind that the user settings in
+ * <filename><replaceable>XDG_CONFIG_HOME</replaceable>/gtk-3.0/gtk.css</filename> will
  * still take precedence over your changes, as it uses the
  * %GTK_STYLE_PROVIDER_PRIORITY_USER priority.
  * </para>
index 1e59989bd16053e4d12198ae7423f69c297e723b..731c34600746d5f41c15208e1076239ff0943fbe 100644 (file)
@@ -72,7 +72,7 @@ G_BEGIN_DECLS
  * GTK_STYLE_PROVIDER_PRIORITY_USER:
  *
  * The priority used for the style information from
- * <filename>~/.gtk-3.0.css</filename>.
+ * <filename><replaceable>XDG_CONFIG_HOME</replaceable>/gtk-3.0/gtk.css</filename>
  *
  * You should not use priorities higher than this, to
  * give the user the last word.